;( function () {
    "use strict";
   	var param_map = Result.getLocationParamObject();
    
	 $( function () {
		 
		 $("#tijiao").click(function(){
			 login();
		 });
		 
		 $("#backIndex").click(function(){
			 Result.forward("../news/newsIndex.html", {});
		 });
		 
		 $("#zhuce_action").click(function(){
			 Result.forward("zhuce.html", {});
		 });
	 });
	 
	 function login(){
		 var $form = $( "#login_form" );
 		 $form.find("input").each( function () {
 			 $( this ).keydown( function () {
	        	if($( this ).hasClass('result-invalid')){
	           		$( this ).removeClass('result-invalid');
	           	}
 			 } );
 		 } ); 
	 		
		if ( Result.validateForm( $form ) === true ) {
			var params = Result.getFormData( $form, true );
			var postParams = {};
			postParams.username = params.account;
			postParams.pwd = hex_md5(params.password);
			postParams.type = 0;
			
        	Result.doResult( {
            	url: Interface.zs.userLogin,
               	type: "POST",
               	async: false,
               	data : postParams
           	}, function ( data) {
				Result.alert("登录成功");
				App.setUser(data);
				 setTimeout(function () {
    				Result.forward("../news/newsIndex.html", {});
    		     }, 100);
           	}, function ( desc ) {
                Result.alert( "对不起:" + desc );
            }, function ( err ) {
                Result.alert( "错误:" + JSON.stringify(err));
            } );
		}
	 }
	 
	 
		 
	
}( window ) );
